package com.iqiyi.dbagent.model;

import java.io.Serializable;
import java.nio.file.Path;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.iqiyi.dbagent.base.config.CommParme.DEALAFTER;
import com.iqiyi.dbagent.base.config.CommParme.DEALTYPE;

/**
 * @Title: DealAfter.java
 * @Package com.iqiyi.dbagent.model
 * @Description: TODO(对处理结果进行跟踪分析)
 * @author wangnianming
 * @date 2015年11月19日 下午5:48:58
 * @version V1.0
 */
public class DealAfter implements Serializable {

	private static final long serialVersionUID = 1L;

	/** 处理数据类型决定处理方式 */
	private DEALTYPE dealType;

	/** 处理输入路径 */
	private Path inputPath;

	/** 处理输出路径 */
	private Path outpuPath;

	/** 处理开始时间 */
	private Date dealStartTime;

	/** 处理结束时间 */
	private Date dealEndTime;

	/** 数据结果大小 */
	private Long dealSize;

	/** 将要被处理的结果大小 */
	private Long todoSize;

	/** 需要关注的信息 */
	private StringBuffer noticeInfo;

	/** 处理结果 */
	private DEALAFTER dealAfter;

	/** 日志记录器 */
	private static final Logger logger = LoggerFactory.getLogger(DealAfter.class);

	/**
	 * @return the dealType
	 */
	public DEALTYPE getDealType() {
		return dealType;
	}

	/**
	 * @param dealType
	 *            the dealType to set
	 */
	public void setDealType(DEALTYPE dealType) {
		this.dealType = dealType;
	}

	/**
	 * @return the inputPath
	 */
	public Path getInputPath() {
		return inputPath;
	}

	/**
	 * @param inputPath
	 *            the inputPath to set
	 */
	public void setInputPath(Path inputPath) {
		this.inputPath = inputPath;
	}

	/**
	 * @return the outpuPath
	 */
	public Path getOutpuPath() {
		return outpuPath;
	}

	/**
	 * @param outpuPath
	 *            the outpuPath to set
	 */
	public void setOutpuPath(Path outpuPath) {
		this.outpuPath = outpuPath;
	}

	/**
	 * @return the dealStartTime
	 */
	public Date getDealStartTime() {
		return dealStartTime;
	}

	/**
	 * @param dealStartTime
	 *            the dealStartTime to set
	 */
	public void setDealStartTime(Date dealStartTime) {
		this.dealStartTime = dealStartTime;
	}

	/**
	 * @return the dealEndTime
	 */
	public Date getDealEndTime() {
		return dealEndTime;
	}

	/**
	 * @param dealEndTime
	 *            the dealEndTime to set
	 */
	public void setDealEndTime(Date dealEndTime) {
		this.dealEndTime = dealEndTime;
	}
	
	/**
	 * @return the dealSize
	 */
	public Long getDealSize() {
		return dealSize;
	}
	
	/**
	 * @param dealSize the dealSize to set
	 */
	public void setDealSize(Long dealSize) {
		this.dealSize = dealSize;
	}
	
	/**
	 * @return the todoSize
	 */
	public Long getTodoSize() {
		return todoSize;
	}
	
	/**
	 * @param todoSize the todoSize to set
	 */
	public void setTodoSize(Long todoSize) {
		this.todoSize = todoSize;
	}


	public StringBuffer getNoticeInfo() {
        return noticeInfo;
    }

    public void setNoticeInfo(StringBuffer noticeInfo) {
        this.noticeInfo = noticeInfo;
    }

    public DEALAFTER getDealAfter() {
        return dealAfter;
    }

    public void setDealAfter(DEALAFTER dealAfter) {
        this.dealAfter = dealAfter;
    }


	/**
	 * @param dealType
	 * @param inputPath
	 * @param outpuPath
	 * @param dealStartTime
	 * @param dealEndTime
	 * @param dealSize
	 * @param todoSize
	 */
	public DealAfter(DEALTYPE dealType, Path inputPath, Path outpuPath,
			Date dealStartTime, Date dealEndTime, Long dealSize, Long todoSize) {
		super();
		this.dealType = dealType;
		this.inputPath = inputPath;
		this.outpuPath = outpuPath;
		this.dealStartTime = dealStartTime;
		this.dealEndTime = dealEndTime;
		this.dealSize = dealSize;
		this.todoSize = todoSize;
	}


	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
    @Override
    public String toString() {
        return "DealAfter [dealType=" + dealType + ", inputPath=" + inputPath
                + ", outpuPath=" + outpuPath + ", dealStartTime="
                + dealStartTime + ", dealEndTime=" + dealEndTime
                + ", dealSize=" + dealSize + ", todoSize=" + todoSize
                + ", noticeInfo=" + noticeInfo + ", dealAfter=" + dealAfter
                + "]";
    }

    public DealAfter() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * 讲文本封装成结果数据
	 * 
	 * @param str
	 * @return
	 */
	public DealAfter fromString(String str) {

		return this;
	}

	/**
	 * 格式化结果返回
	 * 
	 * @return
	 */
	public StringBuffer formatResult() {
		StringBuffer sbf = new StringBuffer();
		sbf.append("+++++++\n");
		sbf.append("输入路径: " + inputPath + "\n");
		sbf.append("处理类型: " + dealType + "\n");
		sbf.append("开始时间: " + dealStartTime + "\n");
		sbf.append("结束时间: " + dealEndTime + "\n");
		sbf.append("预处理任务量: " + todoSize + "\n");
		sbf.append("处理结果量: " + dealSize + "\n");
		sbf.append("处理结果详细: "+ noticeInfo + "\n");
		sbf.append("输出路径: " + outpuPath + "\n");
		sbf.append("-------\n");
		logger.info(sbf.toString());
		return sbf;
	}
}
